POV-Ray : Newsgroups : povray.newusers : arrays and random numbers : Re: arrays and random numbers Server Time
5 Sep 2024 16:16:22 EDT (-0400)
  Re: arrays and random numbers  
From: CMcCabe
Date: 9 Apr 2000 20:01:11
Message: <38F1196B.30A6CB16@fcmail.com>
I realized this myself after looking at the code to the sphere and
superellipsoid scene again.  But thank you both very much for explaining that
random numbers can't be seeded and found at the same time.
Now I seem to be having another problem...
Is it possible to only initialize some positions of an array?  As in maybe
every array[X] where X is even?
Here's the code that I am trying to use:
#declare SNum = seed(8);
#declare RNum = int ( 10 * rand ( SNum ) );
#declare XPos = 0;
#declare ZPos = 0;
#declare CityArray = array [100][100]
#declare FCount = 0;

#declare Floor =
box { <XPos,0,ZPos>, <XPos+9,8,ZPos+9> pigment {Blue} }

#while (XPos < 100)
  #while (ZPos < 100 )
    #declare CityArray[XPos][ZPos]=RNum;
    #while (FCount <= CityArray[XPos][ZPos])
      object{Floor translate <0,FCount*8,0>}
      #declare FCount = FCount + 1;
    #end//while fcount
    #declare ZPos = ZPos + 10;
  #end//while zpos
  #declare XPos = XPos + 10;
#end//while xpos

When I run this I get a scene containing four floor objects, although I
thought that there would be many more floor objects than that.  So it seems
to me that the while loops are executing once and only once.  Any ideas as to
why would be greatly appreciated.

CMcCabe


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.